package com.enjoy.concurrent.ch2;

import lombok.extern.slf4j.Slf4j;

import java.util.Arrays;
import java.util.concurrent.CountDownLatch;

@Slf4j(topic = "enjoy")
public class CountDownLatchTest {
    private static final CountDownLatch countDownLatch = new CountDownLatch(1);

    public static void main(String[] args) throws InterruptedException {
        for (int i = 0; i < 8; i++) {
            new Thread(() -> {
                try {
                    countDownLatch.await();
                } catch (InterruptedException e) {
                    log.error(Arrays.toString(e.getStackTrace()));
                }
                log.info("准备好了");
            }, "t" + i).start();
        }


        log.info("冲!!!");
        Thread.sleep(10000);
        countDownLatch.countDown();
    }
}
